<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Ubuntu20.04下，搭建hexo个人博客 | 细粒丁の小窝</title><meta name="keywords" content="虚拟机,Linux,博客,hexo,nginx"><meta name="author" content="细粒丁"><meta name="copyright" content="细粒丁"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="一些说明和资源所使用到的软件版本：    Ubuntu Nginx Git hexo    20.04 LTS 1.18.0 2.25.1 5.4.0.   其他说明：这里所演示的是在 VirtualBox 中进行的，实际工作场景可以是云服务器上（因为我通常在虚拟机折腾完之后再同步到服务器hhh）  大致的布局和思路  安装Ubuntu 20.04 LTS这里先挖个坑，后续再补充文章… 这里可以参">
<meta property="og:type" content="article">
<meta property="og:title" content="Ubuntu20.04下，搭建hexo个人博客">
<meta property="og:url" content="https://tenyding.cn/%E6%8A%80%E6%9C%AF/Ubuntu20-04%E4%B8%8B%EF%BC%8C%E6%90%AD%E5%BB%BAhexo%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/index.html">
<meta property="og:site_name" content="细粒丁の小窝">
<meta property="og:description" content="一些说明和资源所使用到的软件版本：    Ubuntu Nginx Git hexo    20.04 LTS 1.18.0 2.25.1 5.4.0.   其他说明：这里所演示的是在 VirtualBox 中进行的，实际工作场景可以是云服务器上（因为我通常在虚拟机折腾完之后再同步到服务器hhh）  大致的布局和思路  安装Ubuntu 20.04 LTS这里先挖个坑，后续再补充文章… 这里可以参">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://tenyding.cn/image/bg7.jpg">
<meta property="article:published_time" content="2021-12-15T03:07:32.000Z">
<meta property="article:modified_time" content="2021-12-15T08:09:46.396Z">
<meta property="article:author" content="细粒丁">
<meta property="article:tag" content="虚拟机">
<meta property="article:tag" content="Linux">
<meta property="article:tag" content="博客">
<meta property="article:tag" content="hexo">
<meta property="article:tag" content="nginx">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://tenyding.cn/image/bg7.jpg"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://tenyding.cn/%E6%8A%80%E6%9C%AF/Ubuntu20-04%E4%B8%8B%EF%BC%8C%E6%90%AD%E5%BB%BAhexo%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//hm.baidu.com"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="manifest" href="/img/pwa/manifest.json"/><link rel="apple-touch-icon" sizes="180x180" href="/img/pwa/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="/img/pwa/32.png"/><link rel="icon" type="image/png" sizes="16x16" href="/img/pwa/16.png"/><link rel="mask-icon" href="https://cdn.jsdelivr.net/gh/li1055107552/My-blog@master/img/pwa/safari-pinned-tab.svg" color="#5bbad5"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="/cdn/cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="/cdn/cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?8f6becbae63b8ad7610d7ae36666ce2e";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":50,"languages":{"author":"作者: 细粒丁","link":"链接: ","source":"来源: 细粒丁の小窝","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#121212","position":"top-center"},
  source: {
    jQuery: '/cdn/cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: '/cdn/cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: '/cdn/cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: '/cdn/cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: '/cdn/cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Ubuntu20.04下，搭建hexo个人博客',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2021-12-15 16:09:46'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const fontSizeVal = saveToLocal.get('global-font-size')
    if (fontSizeVal !== undefined) {
      document.documentElement.style.setProperty('--global-font-size', fontSizeVal + 'px')
    }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/css/csdn/iconfont.css"><meta name="generator" content="Hexo 5.4.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="/image/avatar.jpg" onerror="onerror=null;src='/image/loading.webp'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">17</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">24</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">4</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 文章归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 文章标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 文章分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/image/bg7.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">细粒丁の小窝</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 文章归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 文章标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 文章分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Ubuntu20.04下，搭建hexo个人博客</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-12-15T03:07:32.000Z" title="发表于 2021-12-15 11:07:32">2021-12-15</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2021-12-15T08:09:46.396Z" title="更新于 2021-12-15 16:09:46">2021-12-15</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%8A%80%E6%9C%AF/">技术</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="Ubuntu20.04下，搭建hexo个人博客"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="一些说明和资源"><a href="#一些说明和资源" class="headerlink" title="一些说明和资源"></a>一些说明和资源</h1><p>所使用到的软件版本：</p>
<table>
<thead>
<tr>
<th align="center">Ubuntu</th>
<th align="center">Nginx</th>
<th align="center">Git</th>
<th align="center">hexo</th>
</tr>
</thead>
<tbody><tr>
<td align="center">20.04 LTS</td>
<td align="center">1.18.0</td>
<td align="center">2.25.1</td>
<td align="center">5.4.0.</td>
</tr>
</tbody></table>
<p>其他说明：这里所演示的是在 VirtualBox 中进行的，实际工作场景可以是云服务器上<br>（因为我通常在虚拟机折腾完之后再同步到服务器hhh）</p>
<hr>
<h1 id="大致的布局和思路"><a href="#大致的布局和思路" class="headerlink" title="大致的布局和思路"></a>大致的布局和思路</h1><p><img src= "" data-lazy-src="https://img-blog.csdnimg.cn/4b4a0a93d9cc4cf5b5c601a8e64e2878.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA57uG57KS5LiB,size_20,color_FFFFFF,t_70,g_se,x_16" alt="大致的布局和思路"></p>
<hr>
<h1 id="安装Ubuntu-20-04-LTS"><a href="#安装Ubuntu-20-04-LTS" class="headerlink" title="安装Ubuntu 20.04 LTS"></a>安装Ubuntu 20.04 LTS</h1><p>这里先挖个坑，后续再补充文章…</p>
<p>这里可以参考这位老哥的：<a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_45763600/article/details/114833521">安装Ubuntu 20.04 LTS服务器的图文教程</a><br><br></p>
<hr>
<h1 id="服务端"><a href="#服务端" class="headerlink" title="服务端"></a>服务端</h1><h2 id="安装并配置Nginx"><a href="#安装并配置Nginx" class="headerlink" title="安装并配置Nginx"></a><strong>安装并配置<code>Nginx</code></strong></h2><h3 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h3><p><strong>先更新源：</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> 获得源上的软件包列表信息</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> sudo apt-get update</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> 更新本地软件</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> sudo apt-get upgrade</span></span><br></pre></td></tr></table></figure>
<p><strong>然后安装：</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> -y 表示yes</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> sudo apt-get install -y nginx</span></span><br></pre></td></tr></table></figure>
<p><strong>启动服务器：</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> systemctl start nginx</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> systemctl <span class="built_in">enable</span> nginx</span></span><br></pre></td></tr></table></figure>
<p>nginx默认的配置文件的路径是：<code>/etc/nginx/ </code><br><br></p>
<h3 id="修改配置文件"><a href="#修改配置文件" class="headerlink" title="修改配置文件"></a>修改配置文件</h3><p>我们可以看到<code>/etc/nginx/ </code>目录下的文件<br><img src= "" data-lazy-src="https://img-blog.csdnimg.cn/e7965bea41a34ccc982d7a4450f7fd76.png" alt="/etc/nginx"><br>正常来说应该是 nginx.conf 这个文件，我们编辑它：<br> <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> sudo vim nginx.conf</span></span><br></pre></td></tr></table></figure></p>
<p> 打开后并没有在http下看到我们熟悉的server、listen这些熟悉的东西，但是会看到有这么两行： <img src= "" data-lazy-src="https://img-blog.csdnimg.cn/fa5c9882c0024755b25d80eb88faa797.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA57uG57KS5LiB,size_20,color_FFFFFF,t_70,g_se,x_16" alt="nginx.conf"><br>所以我们可以在 <code>/etc/nginx/conf.d/*.conf</code>下进行配置</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> sudo cp sites-available/default conf.d/default.conf</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> sudo vim default.conf</span></span><br></pre></td></tr></table></figure>
<p><strong>IP改为自己的IP<br> root改为自己的资源路径，这里要与后面Git的勾子对应</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line">server &#123;</span><br><span class="line">		listen 80 default_server;</span><br><span class="line">		listen [::]:80 default_server;</span><br><span class="line">		server_name 192.168.37.131;	// 这里写自己的服务器IP</span><br><span class="line"></span><br><span class="line">		# root /home/xld/hexo;</span><br><span class="line">		# index index.html;</span><br><span class="line"></span><br><span class="line">		location / &#123;</span><br><span class="line">				root /home/xld/hexo;</span><br><span class="line">                index index.html;</span><br><span class="line">                autoindex on;</span><br><span class="line">        &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">// 还可以简单的配置监听多个端口（具体的可以看其他 nginx 的配置）</span><br><span class="line">// server &#123;</span><br><span class="line">//        listen 81;</span><br><span class="line">//        listen [::]:81;</span><br><span class="line">//        server_name 192.168.37.131;</span><br><span class="line">// </span><br><span class="line">//        root /home/xld/api;</span><br><span class="line">//        #index index.html;</span><br><span class="line">// </span><br><span class="line">//        location / &#123;</span><br><span class="line">//                 root /home/xld/api;</span><br><span class="line">//                 autoindex on;</span><br><span class="line">//        &#125;</span><br><span class="line">// &#125;</span><br></pre></td></tr></table></figure>
<p>配置完记得保存然后重新加载一下，这里列出几个常用的nginx命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> nginx -t	// 查看nginx状态（用来测试配置是否正确）</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> nginx -s reload	// 重新载入配置文件</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> nginx -s reopen	// 重启 Nginx</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> nginx -s stop		// 停止 Nginx</span></span><br></pre></td></tr></table></figure>
<p>*<strong>创建hexo文件夹</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> <span class="built_in">cd</span> ~</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> mkdir hexo</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> sudo chmod 775 hexo	// 这里应该是权限问题我没搞懂，不改的话后面git钩子钩过来但权限不足，导致同步不了。</span></span><br></pre></td></tr></table></figure>
<br>

<h2 id="Git仓库"><a href="#Git仓库" class="headerlink" title="Git仓库"></a>Git仓库</h2><h3 id="Git安装和用户创建"><a href="#Git安装和用户创建" class="headerlink" title="Git安装和用户创建"></a>Git安装和用户创建</h3><p><strong>安装git：</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> sudo apt-get install git</span></span><br></pre></td></tr></table></figure>
<p>注：这里往后基本上都是root在进行的，注意切换！</p>
<p><strong>配置git用户：</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> adduser git</span></span><br></pre></td></tr></table></figure>
<p><strong>修改权限：</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> chmod 740 /etc/sudoers</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> vim /etc/sudoers</span></span><br></pre></td></tr></table></figure>
<p>定位到这里，加上 <code>git</code>用户这一行<br><img src= "" data-lazy-src="https://img-blog.csdnimg.cn/72e8a3081ab3405088041c29d27923b2.png" alt="/etc/sudoers"><br><strong>然后保存并退出，将sudoers文件权限改回原样：</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> chmod 400 /etc/sudoers</span></span><br></pre></td></tr></table></figure>
<p><strong>设置git用户的密码：</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> sudo passwd git</span></span><br></pre></td></tr></table></figure>
<p><strong>切换到git用户，然后在<code>~</code>目录下创建 <code>.ssh </code>文件夹：</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> su git</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> <span class="built_in">cd</span> ~</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> mkdir .ssh</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> <span class="built_in">cd</span> .ssh</span></span><br></pre></td></tr></table></figure>
<p><strong>生成公钥密钥文件：</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> ssh-keygen</span></span><br></pre></td></tr></table></figure>
<p><strong>将公钥文件复制一份：</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> cp id_rsa.pub authorized_keys</span></span><br></pre></td></tr></table></figure>
<p><strong>修改<code>authorized_keys</code>的权限：</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> chmod 755 ~</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> chmod 700 ~/.ssh</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> chmod 600 ~/.ssh/authorized_keys</span></span><br></pre></td></tr></table></figure>
<p>然后保存并退出后，我们就可以利用ssh连接和登陆<code>git</code>用户啦~<br><br></p>
<h3 id="Git的勾子hooks"><a href="#Git的勾子hooks" class="headerlink" title="Git的勾子hooks"></a>Git的勾子hooks</h3><p><strong>创建仓库</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> su root</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> <span class="built_in">cd</span> /home/git</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> git init --bare blog.git		// 在/home/git下创建新仓库blog.git</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> chown git:git -R blog.git		// 给予git用户权限</span></span><br></pre></td></tr></table></figure>
<p>在<code> /home/hexo/blog.git/hookd</code> 下创建一个 <code>post-receive</code> 文件<br>把提交到 <code>/home/git/blog.git</code> 仓库里的文件同步到 <code> /home/xld/hexo</code>（上文nginx的root资源目录） 中。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> <span class="built_in">cd</span> blog.git/hooks/</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> vim post-receive</span></span><br></pre></td></tr></table></figure>
<p>在 post-receive 中添加以下内容：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">#!/bin/bash</span><br><span class="line">git --work-tree=/home/xld/hexo --git-dir=/home/git/blog.git checkout -f</span><br></pre></td></tr></table></figure>
<p><strong>保存退出，添加可执行权限：</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">chmod +x /home/git/blog.git/hooks/post-receive</span><br></pre></td></tr></table></figure>
<br>

<hr>
<h1 id="本地端"><a href="#本地端" class="headerlink" title="本地端"></a>本地端</h1><h2 id="安装node-js"><a href="#安装node-js" class="headerlink" title="安装node.js"></a>安装<code>node.js</code></h2><p>菜鸟教程，你值得拥有：<a target="_blank" rel="noopener" href="https://www.runoob.com/nodejs/nodejs-install-setup.html">Node.js 安装配置</a><br><br></p>
<h2 id="hexo"><a href="#hexo" class="headerlink" title="hexo"></a>hexo</h2><p>进入到你的<code>blog</code>文件夹下（比如我是windows，就<code>cmd</code>进入到 <code>E:\blog</code> 目录下）</p>
<h3 id="安装-amp-初始化"><a href="#安装-amp-初始化" class="headerlink" title="安装&amp;初始化"></a>安装&amp;初始化</h3><p><strong>安装</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> npm install -g hexo-cli</span></span><br><span class="line"></span><br><span class="line">// 安装成功后可以查看相关信息</span><br><span class="line"><span class="meta">$</span><span class="bash"> hexo -v</span></span><br></pre></td></tr></table></figure>
<p><strong>初始化一个博客</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> hexo init</span></span><br></pre></td></tr></table></figure>
<p><strong>启动博客</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> hexo s</span></span><br></pre></td></tr></table></figure>
<p>启动之后我们就可以在浏览器输入<code>localhost:4000</code>进行访问了<br>然后你就可以看到 Hello World 文章和它的四个常用命令<br><br></p>
<h3 id="部署到服务端"><a href="#部署到服务端" class="headerlink" title="部署到服务端"></a>部署到服务端</h3><p><strong>打开文件夹下的 <code>_config.yml</code> 文件</strong>：</p>
<p>找到 <code>deploy</code> 这一项，然后按格式添加自己的仓库地址<br>（如果你有多个仓库的话，按格式接着写就能一次性git上去）<br><img src= "" data-lazy-src="https://img-blog.csdnimg.cn/7a4880c157cf4007891b18b1f5baa998.png" alt="deploy"><br>保存退出，然后顺便把服务端也停掉（上面的 <code>hexo s</code>）</p>
<p><strong>清除旧文件&amp;重新生成&amp;发布：</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> hexo clean &amp; hexo g &amp; hexo d</span></span><br></pre></td></tr></table></figure>
<p>直接 <code>$ hexo d</code> 也行，只不过说一下可以这么用而已……</p>
<p>之后等他自动执行发布就好了，如果有提示你输入git用户/密码，照着输入就行<br>之后有ssh就会方便一点<br><br></p>
<h2 id="访问服务端进行浏览"><a href="#访问服务端进行浏览" class="headerlink" title="访问服务端进行浏览"></a>访问服务端进行浏览</h2><p>返回 <strong>Ubuntu LTS</strong> 上，在 <code>/home/xld/hexo</code> 应该能看到 <code>hexo</code> 自动发布的东西<br>如果你 <code>nginx</code> 没啥问题的话，这时在其他电脑的浏览器上，输入IP地址，就能访问到刚刚那篇 <strong>Hello World</strong> 文章啦~</p>
<p>再回过头来看开局的那张图。。。</p>
<p>这简陋的界面多少都有点接受不了吧…这时就可以去到hexo官网 找到一个自己喜欢的主题进行魔改吧~<br><br></p>
<hr>
<h1 id="参考文章"><a href="#参考文章" class="headerlink" title="参考文章"></a>参考文章</h1><ul>
<li><a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_45763600/article/details/114833521">安装Ubuntu 20.04 LTS服务器的图文教程</a></li>
<li><a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_52154011/article/details/111402551">从零搭建Hexo博客并部署腾讯云服务器（宝宝级教学）</a></li>
<li><a target="_blank" rel="noopener" href="https://hexo.io/">hexo官网</a></li>
<li><a target="_blank" rel="noopener" href="https://www.php.cn/nginx/434058.html">nginx怎么配置</a></li>
<li><a target="_blank" rel="noopener" href="https://www.git-scm.com/book/zh/v2/%E8%87%AA%E5%AE%9A%E4%B9%89-Git-Git-%E9%92%A9%E5%AD%90">Git 钩子</a></li>
</ul>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">细粒丁</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://tenyding.cn/%E6%8A%80%E6%9C%AF/Ubuntu20-04%E4%B8%8B%EF%BC%8C%E6%90%AD%E5%BB%BAhexo%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/">https://tenyding.cn/技术/Ubuntu20-04下，搭建hexo个人博客/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://tenyding.cn" target="_blank">细粒丁の小窝</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E8%99%9A%E6%8B%9F%E6%9C%BA/">虚拟机</a><a class="post-meta__tags" href="/tags/Linux/">Linux</a><a class="post-meta__tags" href="/tags/%E5%8D%9A%E5%AE%A2/">博客</a><a class="post-meta__tags" href="/tags/hexo/">hexo</a><a class="post-meta__tags" href="/tags/nginx/">nginx</a></div><div class="post_share"><div class="social-share" data-image="/image/bg7.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="/cdn/cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="/cdn/cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button button--animated"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/img/wechat.jpg" target="_blank"><img class="post-qr-code-img" src= "" data-lazy-src="/img/wechat.jpg" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/img/alipay.jpg" target="_blank"><img class="post-qr-code-img" src= "" data-lazy-src="/img/alipay.jpg" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/%E7%B2%BE%E9%80%9A%E5%90%84%E8%BD%AF%E4%BB%B6%E7%9A%84%E5%AE%89%E8%A3%85/Kafka%E5%AE%89%E8%A3%85%E4%B8%8E%E9%85%8D%E7%BD%AE/"><img class="prev-cover" src= "" data-lazy-src="/image/bg8.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">大型数据库（8）--- Kafka安装与配置</div></div></a></div><div class="next-post pull-right"><a href="/%E6%8A%80%E6%9C%AF/%E8%83%BD%E4%B8%80%E9%94%AE%E5%A4%87%E4%BB%BD%E7%9A%84%E5%BF%AB%E6%8D%B7%E6%96%B9%E5%BC%8F/"><img class="next-cover" src= "" data-lazy-src="/image/bg7.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">能一键备份的快捷方式</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/精通各软件的安装/HBase安装与配置/" title="大型数据库（2）--- HBase安装与配置"><img class="cover" src= "" data-lazy-src="/image/bg4.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-09-18</div><div class="title">大型数据库（2）--- HBase安装与配置</div></div></a></div><div><a href="/精通各软件的安装/Hive安装与配置/" title="大型数据库（1）--- Hive安装与配置"><img class="cover" src= "" data-lazy-src="/image/bg7.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-09-18</div><div class="title">大型数据库（1）--- Hive安装与配置</div></div></a></div><div><a href="/精通各软件的安装/Mahout安装与配置/" title="大型数据库（3）--- Mahout安装与配置"><img class="cover" src= "" data-lazy-src="/image/bg11.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-09-18</div><div class="title">大型数据库（3）--- Mahout安装与配置</div></div></a></div><div><a href="/精通各软件的安装/Kafka安装与配置/" title="大型数据库（8）--- Kafka安装与配置"><img class="cover" src= "" data-lazy-src="/image/bg8.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-09-20</div><div class="title">大型数据库（8）--- Kafka安装与配置</div></div></a></div><div><a href="/精通各软件的安装/Spark安装与配置/" title="大型数据库（5）--- Spark安装与配置"><img class="cover" src= "" data-lazy-src="/image/bg4.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-09-19</div><div class="title">大型数据库（5）--- Spark安装与配置</div></div></a></div><div><a href="/精通各软件的安装/Sqoop安装与配置/" title="大型数据库（4）--- Sqoop安装与配置"><img class="cover" src= "" data-lazy-src="/image/bg3.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-09-19</div><div class="title">大型数据库（4）--- Sqoop安装与配置</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="twikoo-wrap"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%B8%80%E4%BA%9B%E8%AF%B4%E6%98%8E%E5%92%8C%E8%B5%84%E6%BA%90"><span class="toc-number">1.</span> <span class="toc-text">一些说明和资源</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%A4%A7%E8%87%B4%E7%9A%84%E5%B8%83%E5%B1%80%E5%92%8C%E6%80%9D%E8%B7%AF"><span class="toc-number">2.</span> <span class="toc-text">大致的布局和思路</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AE%89%E8%A3%85Ubuntu-20-04-LTS"><span class="toc-number">3.</span> <span class="toc-text">安装Ubuntu 20.04 LTS</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%9C%8D%E5%8A%A1%E7%AB%AF"><span class="toc-number">4.</span> <span class="toc-text">服务端</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85%E5%B9%B6%E9%85%8D%E7%BD%AENginx"><span class="toc-number">4.1.</span> <span class="toc-text">安装并配置Nginx</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85"><span class="toc-number">4.1.1.</span> <span class="toc-text">安装</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="toc-number">4.1.2.</span> <span class="toc-text">修改配置文件</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Git%E4%BB%93%E5%BA%93"><span class="toc-number">4.2.</span> <span class="toc-text">Git仓库</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Git%E5%AE%89%E8%A3%85%E5%92%8C%E7%94%A8%E6%88%B7%E5%88%9B%E5%BB%BA"><span class="toc-number">4.2.1.</span> <span class="toc-text">Git安装和用户创建</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Git%E7%9A%84%E5%8B%BE%E5%AD%90hooks"><span class="toc-number">4.2.2.</span> <span class="toc-text">Git的勾子hooks</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%9C%AC%E5%9C%B0%E7%AB%AF"><span class="toc-number">5.</span> <span class="toc-text">本地端</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85node-js"><span class="toc-number">5.1.</span> <span class="toc-text">安装node.js</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#hexo"><span class="toc-number">5.2.</span> <span class="toc-text">hexo</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-amp-%E5%88%9D%E5%A7%8B%E5%8C%96"><span class="toc-number">5.2.1.</span> <span class="toc-text">安装&amp;初始化</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%83%A8%E7%BD%B2%E5%88%B0%E6%9C%8D%E5%8A%A1%E7%AB%AF"><span class="toc-number">5.2.2.</span> <span class="toc-text">部署到服务端</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%AE%BF%E9%97%AE%E6%9C%8D%E5%8A%A1%E7%AB%AF%E8%BF%9B%E8%A1%8C%E6%B5%8F%E8%A7%88"><span class="toc-number">5.3.</span> <span class="toc-text">访问服务端进行浏览</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%8F%82%E8%80%83%E6%96%87%E7%AB%A0"><span class="toc-number">6.</span> <span class="toc-text">参考文章</span></a></li></ol></div></div></div></div></main><footer id="footer" style="background-image: url('/image/bg7.jpg')"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2022 By 细粒丁</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text"><a target="_blank" rel="noopener" href="https://beian.miit.gov.cn/"><span>粤ICP备20048893号</span></a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="font-plus" type="button" title="放大字体"><i class="fas fa-plus"></i></button><button id="font-minus" type="button" title="缩小字体"><i class="fas fa-minus"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/cdn/cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="/cdn/cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="/cdn/cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.autoSpacingPage()
  else {
    getScript('/cdn/cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js')
      .then(() => {
        pangu.autoSpacingPage()
      })
  }
}

function panguInit () {
  if (true){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguInit)</script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>if (document.getElementsByClassName('mermaid').length) {
  if (window.mermaidJsLoad) mermaid.init()
  else {
    getScript('/cdn/cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(() => {
      window.mermaidJsLoad = true
      mermaid.initialize({
        theme: 'default',
      })
      false && mermaid.init()
    })
  }
}</script><script>(()=>{
  const $countDom = document.getElementById('twikoo-count')
  const init = () => {
    twikoo.init(Object.assign({
      el: '#twikoo-wrap',
      envId: 'tenyding-17a635',
      region: ''
    }, null))
  }

  const getCount = () => {
    twikoo.getCommentsCount({
      envId: 'tenyding-17a635',
      region: '',
      urls: [window.location.pathname],
      includeReply: false
    }).then(function (res) {
      $countDom.innerText = res[0].count
    }).catch(function (err) {
      console.error(err);
    });
  }

  const loadTwikoo = (bool = false) => {
    if (typeof twikoo === 'object') {
      init()
      bool && $countDom && setTimeout(getCount,0)
    } else {
      getScript('/cdn/cdn.jsdelivr.net/npm/twikoo@1.4.18/dist/twikoo.all.min.js').then(()=> {
        init()
        bool && $countDom && setTimeout(getCount,0)
      })
    }
  }

  if ('Twikoo' === 'Twikoo' || !true) {
    if (true) btf.loadComment(document.getElementById('twikoo-wrap'), loadTwikoo)
    else loadTwikoo(true)
  } else {
    window.loadOtherComment = () => {
      loadTwikoo()
    }
  }
})()</script></div><script id="click-heart" src="/cdn/cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-heart.min.js" async="async" mobile="false"></script><link rel="stylesheet" href="/cdn/cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="/cdn/cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="/cdn/cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start -->
  <script data-pjax src="/cdn/cdn.jsdelivr.net/gh/Zfour/hexo-github-calendar@1.21/hexo_githubcalendar.js"></script>
  <script data-pjax>
        function GithubCalendarConfig(){
            var git_githubapiurl ="https://python-github-calendar-api.vercel.app/api?li1055107552";
            var git_color =['#ebedf0', '#fdcdec', '#fc9bd9', '#fa6ac5', '#f838b2', '#f5089f', '#c4067e', '#92055e', '#540336', '#48022f', '#30021f'];
            var git_user ="li1055107552";
            var parent_div_git = document.getElementById('recent-posts');
            var git_div_html = ' <div class="recent-post-item" style="width:100%;height:auto;padding:10px;"> <div id="github_loading" style="width:10%;height:100%;margin:0 auto;display: block"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"  viewBox="0 0 50 50" style="enable-background:new 0 0 50 50" xml:space="preserve"> <path fill="#d0d0d0" d="M25.251,6.461c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615V6.461z" transform="rotate(275.098 25 25)"> <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"> </animateTransform> </path> </svg> </div> <div id="github_container"></div> </div>';
            if(parent_div_git && location.pathname =='/'){
                console.log('已挂载github calendar')
                // parent_div_git.innerHTML=git_div_html+parent_div_git.innerHTML // 无报错，但不影响使用(支持pjax跳转)
                parent_div_git.insertAdjacentHTML("afterbegin",git_div_html) // 有报错，但不影响使用(支持pjax跳转)
            };
            GithubCalendar(git_githubapiurl,git_color,git_user)
        }
        if(document.getElementById('recent-posts')){
            GithubCalendarConfig()
        }
    </script>
    <style>#github_container{min-height:280px}@media screen and (max-width:650px) {#github_container{background-image:;min-height:0px}}</style>
    <style></style><!-- hexo injector body_end end --></body></html>